package com.guigusuqi.commonutils.utils;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.Calendar;
import java.util.Date;

@Data
@AllArgsConstructor
public class GetMonthByDateUtils
{
    public static int getMonthByDate(Date date)
    {
        //  获取当前是几月
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        return cal.get(Calendar.MONTH);
    }

    public static int getYearByDate(Date date)
    {
        //  获取当前的年份
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        return cal.get(Calendar.YEAR);
    }
}
